﻿using BlogApi.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace BlogApi.Services
{
    /// <summary>
    /// 点赞表的仓储接口
    /// </summary>
    public interface ILikeRepository
    {
        /// <summary>
        /// 获取所有点赞表的数据
        /// </summary>
        /// <returns></returns>
        Task<IEnumerable<Like>> GetLikesAsync();
        /// <summary>
        /// 根据用户ID获取点赞表数据
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        Task<IEnumerable<Like>> GetLikesByUserIdAsync(Guid userId);
        /// <summary>
        /// 跟据点赞表的ID获取数据
        /// </summary>
        /// <param name="likeId"></param>
        /// <returns></returns>
        Task<Like> GetLikeAsync(Guid likeId);
        /// <summary>
        /// 根据文章Id和用户ID获取数据
        /// </summary>
        /// <param name="articleId"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        Task<Like> GetLikeAsync(Guid articleId, Guid userId);
        /// <summary>
        /// 点赞表新增一条数据
        /// </summary>
        /// <param name="like"></param>
        void AddLike(Like like);
        /// <summary>
        /// 更新一条数据
        /// </summary>
        /// <param name="like"></param>
        void UpdateLike(Like like);
        /// <summary>
        /// 删除一条数据
        /// </summary>
        /// <param name="like"></param>
        void DeleteLike(Like like);
        /// <summary>
        /// 根据点赞表ID判断数据是否存在
        /// </summary>
        /// <param name="likeId"></param>
        /// <returns></returns>
        Task<bool> LikeExistsAsync(Guid likeId);
        /// <summary>
        /// 根据用户和文章ID判断该用户是否给文章点赞
        /// </summary>
        /// <param name="articleId"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        Task<bool> UserLikeArticleExistsAsync(Guid articleId, Guid userId);
        /// <summary>
        /// 保存更改到数据库
        /// </summary>
        /// <returns></returns>
        Task<bool> SaveAsync();
    }
}
